import { request } from '../utils/request.js'
import store from '../store'
import { Toast, Jump } from '../utils/tools.js'
import md5 from 'js-md5'
import { balance } from '@/api/Users.js'
import { GetShopCar } from "@/api/Goods.js"

// 已支付待提货 打印机 订单 退款申请操作
export async function refundApply(params) {
	try {
		let res = await request({
			url: '/Order/refundApply',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return false
	}
}

//我的开票 记录
export async function invr(params) {
	try {
		let res = await request({
			url: '/Order/invr',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return false
	}
}
//我的发票 列表
export async function invs(params) {
	try {
		let res = await request({
			url: '/Order/invs',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return false
	}
}
//申请开票
export async function inva(params) {
	try {
		let res = await request({
			url: '/Order/inva',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return false
	}
}
//x新增发票信息
export async function inve(params) {
	try {
		let res = await request({
			url: '/Order/inve',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return false
	}
}
//创建訂單提貨
export async function takout(params) {
	try {
		let res = await request({
			url: '/Order/takout',
			method: "post",
			params
		})
		if (res.success) {
			// const { success, list } = await GetShopCar({
			// 	pageIndex: 1,
			// 	pageSize: 50,
			// });
			// store.commit('goods/SET_CARTLIST', list);
		}
		return res
	} catch (e) {
		return false
	}
}
//创建打印机订单
export async function CreateOrder_1(params) {
	try {
		let res = await request({
			url: '/Order/CreateOrder_1',
			method: "post",
			params
		})
		if (res.success) {
			// const { success, list } = await GetShopCar({
			// 	pageIndex: 1,
			// 	pageSize: 50,
			// });
			// store.commit('goods/SET_CARTLIST', list);
		}
		return res
	} catch (e) {
		return false
	}
}
//创建订单
export async function CreateOrder(params) {
	try {
		let res = await request({
			url: '/Order/CreateOrder',
			method: "post",
			params
		})
		if (res.success) {
			// const { success, list } = await GetShopCar({
			// 	pageIndex: 1,
			// 	pageSize: 50,
			// });
			// store.commit('goods/SET_CARTLIST', list);
		}
		return res
	} catch (e) {
		return false
	}
}

export async function First(params) {
	try {
		let res = await request({
			url: '/Order/First',
			method: "post",
			params
		})
		return res
	} catch (e) {

		return false
	}
}


//继续支付
export async function CreatePayOrder(params, data) {
	try {
		let res = await request({
			url: '/Order/CreatePayOrder',
			method: "post",
			params,
			data
		})
		return res
	} catch (e) {
		console.log('e=====>', e)
		return false
	}
}

//订单列表
export async function GetOrderPage(params) {
	try {
		let res = await request({
			url: '/Order/GetOrderPage',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return false
	}
}

//签收
export async function SignIn(params) {
	try {
		let res = await request({
			url: '/Order/SignIn',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return false
	}
}

//评论
export async function Comment(params) {
	try {
		let res = await request({
			url: '/Goods/Comment/Comment',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return false
	}
}

// 设置审订单地址
export async function SetAddr(params) {
	try {
		let res = await request({
			url: '/Order/SetAddr',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return false
	}
}

// 取消订单
export async function CancellOrder(params) {
	try {
		let res = await request({
			url: '/Order/CancellOrder',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return false
	}
}

// 获取订单状态 数量统计
export async function OrderCount() {
	try {
		let res = await request({
			url: '/Order/OrderCount',
			method: "post",
		})
		return res
	} catch (e) {
		return false
	}
}

// 购物车多商品 创建订单
export async function CreateOrder_Car(params, data) {
	try {
		let res = await request({
			url: '/Order/CreateOrder_Car',
			method: "post",
			params,
			data
		})
		if (res.success) {
			// const { success, list } = await GetShopCar({
			// 	pageIndex: 1,
			// 	pageSize: 50,
			// });
			// store.commit('goods/SET_CARTLIST', list);
		}
		return res
	} catch (e) {
		return false
	}
}
// // 购物车多商品 创建订单
// export async function Cashier(params,data) {
// 	try {
// 		let res = await request({
// 			url: '/Order/Cashier',
// 			method: "post",
// 			params,
// 			data
// 		})
// 		return res
// 	} catch (e) {
// 		return false
// 	}
// }

// 售后申请
export async function AftersellOrderApply(params) {
	try {
		let res = await request({
			url: '/Order/AftersellOrderApply',
			method: "post",
			params,
		})
		return res
	} catch (e) {
		return false
	}
}